mickey krekels's profile

Sint Lucas Project

Project Sint Lucas Game 

Explore the low poly world and find out the hidden secrets. 
Find clues and make puzzels!
complete the game by solving all the puzzles
my unity C# develop coding 


-this code is for dragging and caring items of the ground
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class levatation_Script : MonoBehaviour {
    GameObject mainCamera;
    bool carrying;
    GameObject carriedObject;
    public float distance;
    public float smooth;
    void Start () {
        mainCamera = GameObject.FindWithTag("MainCamera");
    }
        
    void Update () {
        if(carrying) {
            carry(carriedObject);
            checkDrop();
            ScrollDistance ();
        } else {
            pickup();
        }
    }
    void rotateObject() {
        carriedObject.transform.Rotate(5,10,15);
    }
    void carry(GameObject o) {
        o.transform.position = Vector3.Lerp (o.transform.position, mainCamera.transform.position + mainCamera.transform.forward * distance, Time.deltaTime * smooth);
        o.transform.rotation = Quaternion.identity;
    }
    void pickup() {
        if(Input.GetKeyDown (KeyCode.E)) {
            int x = Screen.width / 2;
            int y = Screen.height / 2;
            Ray ray = mainCamera.GetComponent<Camera>().ScreenPointToRay(new Vector3(x,y));
            RaycastHit hit;
            if(Physics.Raycast(ray, out hit)) {
                Pickupable p = hit.collider.GetComponent<Pickupable>();
                if(p != null) {
                    carrying = true;
                    carriedObject = p.gameObject;
                    p.gameObject.GetComponent<Rigidbody>().useGravity = false;
                }
            }
        }
    }
    void checkDrop() {
        if(Input.GetKeyDown (KeyCode.E)) {
            dropObject();
        }
    }
    public void dropObject() {
        carrying = false;
        carriedObject.gameObject.GetComponent<Rigidbody>().useGravity = true;
        carriedObject = null;
        distance = 2;
    }
    void ScrollDistance ()
    {
        var d = Input.GetAxis ("Mouse ScrollWheel");
        if (d > 0f && distance < 5) {
            distance++;

        } else if (d < 0f && distance > 1) {
            distance--;
        }
    }
}
-this script is for pointing out the objects you can carry and giving them an ID 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pickupable : MonoBehaviour {
    public int ID;
    // Use this for initialization
    void Start () {
        
    }
    
    // Update is called once per frame
    void Update () {
        
    }
}

-this is the padlock script 
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine;

public class padlockScript : MonoBehaviour {
    public bool num1;
    public bool num2;
    public bool num3;
    public Text text_1;
    public Text text_2;
    public Text text_3;
    public GameObject uiUnlockScreen;
    public GameObject player;
    // Use this for initialization
    void Start () {
        num1 = false;
        num2 = false;
        num3 = false;
        uiUnlockScreen.SetActive(false);
    }

    // Update is called once per frame
    void Update ()
    {
      if (player.GetComponent<playerScript_2>().doorlock == true){
            uiUnlockScreen.SetActive(true);
            DoorLock ();
        }
        if (num1 == true && num2 == true && num3 == true) {
            Debug.Log ("Het WERKT");
            SceneManager.LoadScene (2);
        }
    }
    void DoorLock(){
        if (Input.GetKey (KeyCode.Alpha3)) {
            num1 = true;
            if (num1 == true) {
                text_1.text = "3";
            }
        }
        if (Input.GetKey (KeyCode.Alpha6)) {
            num2 = true;
            if (num2 == true) {
                text_2.text = "6";
            }
        }
        if (Input.GetKey (KeyCode.Alpha9)) {
            num3 = true;
            if (num3 = true) {
                text_3.text = "9";
            }
        }
    }
}

-this script is there for travelling thru the scenes in the game
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;
public class playerScript_2 : MonoBehaviour {
    public bool doorlock = false;
    void Start() {
        
    }
    void Update () {
        RaycastHit hit;

        // Debug Raycast in the Editor - laat de Raycast in editor mode zien-
        if (Input.GetKey (KeyCode.E)) {
            Vector3 forward = transform.TransformDirection (Vector3.forward) * 2;
            Debug.DrawRay (transform.position, forward, Color.green);
            if (Physics.Raycast (transform.position, (forward), out hit)) {
                if (hit.collider.gameObject.CompareTag ("Door")) {
                    
                    doorlock = true;
                }
                if (hit.collider.gameObject.CompareTag ("Door2")) {
                    
                    SceneManager.LoadScene (3);
                }
                if (hit.collider.gameObject.CompareTag ("Door3")) {
                    SceneManager.LoadScene (2);
                }
                if (hit.collider.gameObject.CompareTag ("Door4")) {
                    SceneManager.LoadScene (1);
                }
            }
        
        }
        }
}
Sint Lucas Project
Published:

Project Made For

Sint Lucas Project

Published:

Creative Fields